package com.hq.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hq.service.OrderService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
@Controller
public class OrderController {
    @Resource
    private OrderService orderService;
    @RequestMapping("list.do")
    public String list(@RequestParam(value = "cpage",defaultValue = "1") Integer cpage,
                       Integer  id,
                       String pinpai, Model model) {
        HashMap map = new HashMap();
        map.put("pinpai", pinpai);
        map.put("id", id);
        PageHelper.startPage(cpage, 2);
        List list = orderService.list(map);
        PageInfo pageInfo = new PageInfo(list);
        model.addAttribute("pageInfo", pageInfo);
        model.addAttribute("map", map);
        return "list";
    }
}
